//
//  MainTabBarController.m
//  MyWeiBo
//
//  Created by wpapple on 16/5/30.
//  Copyright © 2016年 heron. All rights reserved.
//

#import "MainTabBarController.h"
#import "MainTabBar.h"

@interface MainTabBarController ()<MainTabBarDelegate>

@end

@implementation MainTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    
    MainTabBar * tabBar = [[MainTabBar alloc]init];
    [tabBar setTintColor:[UIColor orangeColor]];
    [self setValue:tabBar forKey:@"tabBar"];
    tabBar.myDelegate = self;
    
//    self.tabBar.barTintColor = [UIColor redColor];
    
    [self addChildControllerWithStoryboardName:@"Home" withTitle:@"首页" withImageName:@"tabbar_home"];
    [self addChildControllerWithStoryboardName:@"Message" withTitle:@"消息" withImageName:@"tabbar_message_center_selected"];
    [self addChildControllerWithStoryboardName:@"Discover" withTitle:@"发现" withImageName:@"tabbar_discover"];
    [self addChildControllerWithStoryboardName:@"Me" withTitle:@"我" withImageName:@"tabbar_profile"];
}

- (void)mainTabBar:(MainTabBar *)mainTabBar withButton:(UIButton *)btn{
    UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"Compose" bundle:nil];
    UINavigationController * nav = [storyboard instantiateInitialViewController];
    [self presentViewController:nav animated:YES completion:nil];
}

- (void)addChildControllerWithStoryboardName:(NSString *)name withTitle:(NSString *)title withImageName:(NSString *)imageName{
    UIStoryboard * storyboard = [UIStoryboard storyboardWithName:name bundle:nil];
    UINavigationController * navC = [storyboard instantiateInitialViewController];
    
    [navC.tabBarController.tabBar setBackgroundColor:[UIColor grayColor]];
    [navC.tabBarItem setTitle:title];
    [navC.tabBarItem setImage:[UIImage imageNamed:imageName]];

    [self addChildViewController:navC];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
